<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>插入锚点</title>
        <script type="text/javascript" src="../internal.js"></script>
        <style type="text/css">
            *{color: #838383}
            body {
                font-size: 12px;
                width:300px;
                height: 56px;
                overflow: hidden;
                margin:0px;padding:0px;
            }
            .content{
                padding:5px 0 0 15px;
                height:100%;
            }
            input{
                height:21px;
                line-height:21px;
            }
            #web table{padding:0px;margin:0px;position:relative}
            #web table tr{padding:0px;margin:0px; list-style: none;height: 30px; line-height: 30px;}
            
            #web span{ padding-right:4px;}
            .content input{ width:145px;height:21px;background: #FFF;border:1px solid #d7d7d7;padding: 0px; margin: 0px; }
            #anchorName{width:210px;}

           
        </style>
    </head>
    <body>
        <div class="content">
            <div id="web">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td><span>锚点名字：</span><input id="anchorName"  value="" /></td>
                    </tr>
                </table>
            </div>
        </div>
        <script type="text/javascript">
            var anchorInput = document.getElementById('anchorName');
            var img = editor.selection.getRange().getClosedNode();
            if(img && /img/ig.test(img.tagName.toLowerCase()) && img.getAttribute('anchorname')){
                anchorInput.value = img.getAttribute('anchorname');
            }
            function jbind(obj,evt,fun){
                if(obj.addEventListener){  // firefox,w3c
                    obj.addEventListener(evt,fun,false);
                }else{// ie
                    obj.attachEvent("on"+evt,function(){fun.apply(obj);});
                }
            }
            jbind(anchorInput,"keydown",function(evt){
                evt = evt || window.event;
                if(evt.keyCode == 13){
                    editor.execCommand('anchor', anchorInput.value);
                    dialog.close();
                    if(evt.preventDefault){
                        evt.preventDefault();
                    }else{
                        evt.returnValue = false;
                    }
                }
            });
            anchorInput.focus();
            var isIE = !!window.ActiveXObject;
            if (isIE) {
                setTimeout(function (){
                    var r = anchorInput.createTextRange();
                    r.collapse(false);
                    r.select();
                });
            }
            dialog.onok = function (){
                editor.execCommand('anchor', anchorInput.value);
                dialog.close();
            };

        </script>
    </body>
</html>